<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
  <head>

    <title>My JSP 'list_task.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

	  <div th:replace="~{commons/script::script}"></div>
  </head>
  	
  <body>
  <div>
	  <span>视图：</span><span onclick="return whole()" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true">全部</span>|
<!--	  <span id="recycleBin" class="easyui-linkbutton" data-options="iconCls:'icon-recover_deleted',plain:true">返回任务</span>-->
	  <a href="/task/toListTask" class="easyui-linkbutton" data-options="iconCls:'icon-recover_deleted',plain:true">返回任务</a>
	  <a href="javascript:void(0);" onclick="return shanchuall('/task/toClearAll')" class="easyui-linkbutton" data-options="iconCls:'icon-recover_deleted',plain:true">清空回收站</a>
	  &nbsp;
  </div>
  	<div>
  		<select  name="select" class="easyui-combobox theme-textbox-radius" style="width:120px" id="select">
  			<option value="1">任意字段</option>
  			<option value="2">主题</option>
  			<option value="3">创建者</option>
  			<option value="4">负责人</option>
  			<option value="5">优先级</option>
  		</select>
  		<select name="taskVo.creatorUsername" class="easyui-combobox theme-textbox-radius" style="width:100px" >
  			<option value="1">包含</option>
  			<option value="2">人名</option>
  		</select>
  		<input name="subject" type="text" class="easyui-textbox theme-textbox-radius">
  		<a href="javascript:void(0);" onclick="return searchs()" class="easyui-linkbutton" data-options="iconCls:'icon-search'">搜索</a>
  	</div>
 
    <table id="taskList"class="easyui-datagrid">
    	
    </table>

    
  </body>
  <script type="text/javascript">
	  //查询全部任务
	  function whole(url){
		  $("#taskList").datagrid("load",{})
	  }

  		function searchs(){
  			$("#taskList").datagrid("load",{
  			 "subject" : $("input[name=subject]").val(),
			 "select":$("#select").val()
  			})
  		}
	  function shanchuall(url){
		  $.post(url,
				  {},
				  function(data){
					  if(data.success && data){
						  $.messager.alert("提示",data.message)
						  $("#taskList").datagrid("reload");
						  return
					  }
					  $.messager.alert("提示",data.message)

				  },
				  "json"
		  )
	  }
  		function shanchu(id){
					$.post("/task/toDeleteTaskHuishou",
					{"id":id},
					function(data){
					if(data.success && data){
						$.messager.alert("提示",data.message)
						$("#taskList").datagrid("reload");
						return
					}
						$.messager.alert("提示",data.message)

					},
					"json"
					)
  		}
	  function huifu(id){
		  $.post("/task/huiFuTask",
				  {"id":id},
				  function(data){
					  if(data.success && data){
						  $.messager.alert("提示",data.message)
						  $("#taskList").datagrid("reload");
						  return
					  }
					  $.messager.alert("提示",data.message)

				  },
				  "json"
		  )
	  }

		$(function(){
			$("#taskList").datagrid({
				url:"/task/listTaskHuiShou",
				pagination:true,
				toolbar:"#toolbar",
				fitColumns:true,
				idField:"taskid",
				rownumbers:true,
				columns :[
						[
					{field:"id",title:"选择",checkbox:true},
					{field:"subject" ,title:"主题",width:1},
					{field:"aboutUsers",title:"相关信息",width:3},
					{field:"ownerUsername",title:"负责人",width:1},
					{field:"status",title:"状态",width:1},
					{field:"priority",title:"优先级",width:1},
					{field:"creatorUsername",title:"创建者",width:1},
					{field:"dueDate" ,title:"截止日期",width:3},
					{field:"operation",width:2,title:"操作",formatter:function(value,rowData,index){
					return "<a href='javascript:void(0);' onclick='shanchu("+rowData.id+")'>删除</a>"+
							"<a href='javascript:void(0);' onclick='huifu("+rowData.id+")'>恢复</a>"
					}},
					
				]
				],
				
				loadFilter:function(data){
				return {"total":data.data.totalRows,"rows":data.data.result}
				}	
				
			})		
		}) 


  
  </script>
</html>
